<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>
    Array.prototype.myMap = function(callback,thisArg){
        if (typeof callback !== 'function') throw new TypeError('callback is not function')
        if (!this) throw new TypeError('this is null or not defined')
        const result = []
        for(let i = 0; i < this.length;i++){
            result[i] = callback.call(thisArg,this[i],i,this) // map接受的回调函数接收三个参数，数组项，索引，原数组
        }
        return result
    }
    console.log([1,2,3,4,5].map(item=>item*2))
    console.log([1,2,3,4,5].myMap(item=>item*2))
</script>
</html>
